#include <iostream>
#include <unistd.h>
#include <memory>
#include <thread>
#include "ringqueue.hpp"

int main()
{
    std::unique_ptr<ringqueue<int>> buffer(new ringqueue<int>);
    auto producer = [&]()
    {
        int in = 0;
        while(true)
        {
            buffer->Push(in);
            std::cout << "producer send messager: " << in++ << std::endl;
            // sleep(1);
        }
    };

    auto consumer = [&]()
    {
        int out = 0;
        while(true)
        {
            buffer->Pop(&out);
            std::cout << "consumer get message: " << out << std::endl;
            sleep(1);
        }
    };

    std::thread th1(producer);
    std::thread th2(producer);
    std::thread th3(consumer);
    std::thread th4(consumer);
    th1.join();
    th2.join();
    th3.join();
    th4.join();
    
    return 0;
}